package kr.hkit.powerjava.chapter10.Programming;

import java.util.Scanner;

public class Reservation {
	public static final int SIZE = 10;
	private int[] seats;
	Scanner input;

	public Reservation() {
		seats = new int[Reservation.SIZE];
		input = new Scanner(System.in);
	}

	public void showReservation() {
		System.out.println("현재의 예약 상태는 다음과 같습니다.");
		System.out
				.println("----------------------------------------------------------------------------------");
		for (int i = 0; i < seats.length; i++) {
			System.out.printf("%d\t", i);
		}
		System.out.println();
		System.out
				.println("----------------------------------------------------------------------------------");
		for (int i : seats) {
			System.out.printf("%d\t", i);
		}
		System.out.println();
	}

	public void selectseat() {
		int seatnum;
		System.out.print("몇번째 좌석을 예약하시겠습니까?: ");
		seatnum = input.nextInt();
		if (seats[seatnum] == 0) {
			seats[seatnum] = 1;
			System.out.println("예약되었습니다.");
		} else {
			System.out.println("예약이 이미 된 좌석입니다.");
			selectseat();
		}
	}
}
